﻿using System;
using System.Collections.Generic;

namespace Framework.Extensions
{
    public static class ObjectExtensions
    {
        public static IEnumerable<T> Chain<T>(this T source, Func<T, T> fn)
            where T : class
        {
            while (source != null)
            {
                yield return source;
                source = fn(source);
            }
        }
    }
}